export default {
	namespaced: true,
	state: () => ({
		token: uni.getStorageSync('token') || '',
		userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}'),
		cont: 0,
		userName: "",
		driverResult: {
			driverName: "",
			sex: "",
			age: "",
			region: "",
			phoneNumber: "",
			registerCode:'',
			licenseLevel: '0',
			licenseValue: '0',
			idCard: "",
			isCar: false,
		},
		carResult: {
			numberplate: "",
			vehicleType: "",
			brandModel: "",
			specification: "",
			carriageLength: "",
			loadSide: "",
			vehicleHeight: "",
			loadCapacity: "",
			highRoof: false,
			categoryId: ''
		},
		model: {
			licensePhoto: "",
			driverPhoto: "",
			idCardFront: "",
			idCardBack: "",
			drivingLicense: "",
			drivingLicenseCar: "",
			carFortyFive: "",
			roadTransport: '',
			ismodify: true
		},
		aaa: '1'

	}),
	mutations: {
		aasea(state, data) {
			state.aaa = data
		},
		//车辆规格选择
		CarTypeCange(state, data) {
			state.carResult.specification = data.carResult.specification
		},
		//车辆类型选择
		vehicleCange(state, data) {
			state.carResult.categoryId = data.categoryId
			state.carResult.vehicleType = data.vehicleType
			state.carResult.specification = data.specification
		},
		//是否带车
		changeIscar(state, data) {
			state.driverResult.isCar = data.isCar
		},
		//车辆信息
		addCarResult(state, data) {
			for (let k in state.carResult) {
				state.carResult[k] = data[k]
			}
			if (data.vehicleInfoVos) {
				if (data.vehicleInfoVos.length > 0) {
					var resultDate = data.vehicleInfoVos[0];
					resultDate.specification = JSON.parse(resultDate.specification)
					state.carResult.numberplate = resultDate.numberplate
					state.carResult.brandModel = resultDate.brandModel
					state.carResult.specification = resultDate.specification
					state.carResult.vehicleType = resultDate.vehicleType
					state.carResult.carriageLength = resultDate.carriageLength
					state.carResult.loadCapacity = resultDate.loadCapacity
					state.carResult.loadSide = resultDate.loadSide
					state.carResult.vehicleHeight = resultDate.vehicleHeight
				}
			}
		},
		//选择车辆类型
		renewDriverResult(state, data) {
			state.driverResult.licenseLevel = data.licenseLevel
			state.driverResult.licenseValue = data.licenseValue
		},
		//司机信息
		addDriverResult(state, data) {
			for (let k in state.driverResult) {
				state.driverResult[k] = data[k]
				state.driverResult.sex = state.driverResult.sex + ''
			}
			//console.log(data.isCar)
			if (state.driverResult.isCar == '扫描识别后自动填写') {
				state.driverResult.isCar = false
			}
			if (data.licenseLevel != "" && data.licenseLevel != null && data.licenseLevel.value) {
				state.driverResult.licenseLevel = data.licenseLevel.message;
				state.driverResult.licenseValue = data.licenseLevel.value;
			} else {
				state.driverResult.licenseLevel = '请选择'
			}
		},
		//图片数据
		addModel(state, data) {
			for (let k in state.model) {
				state.model[k] = data[k]
			}
			//console.log(data.ismodify,1111111)
		},
		//图片新增
		Photos(state, data) {
			//console.log(data)
			state.model[data.imgname] = data.url
		},

		setToken(state, data) {
			state.token = data
			uni.setStorageSync('token', data)
		},
		removeToken(state) {
			state.token = ''
			uni.removeStorageSync('token')
		},
		setUserinfo(state, data) {
			state.userinfo = data
			uni.setStorageSync('userinfo', JSON.stringify(data))
		},
		removeUserinfo(state) {
			state.userinfo = ''
			uni.removeStorageSync('userinfo')
		},
	},
	actions: {

	}
}